import ACCESS_ENUMS from "@/access/accessEnums";

export default (loginUser: any, needAccess: string) => {
  const loginUserAccess = loginUser.userRole ?? ACCESS_ENUMS.NOT_LOGIN;
  if (needAccess === ACCESS_ENUMS.NOT_LOGIN) {
    return true;
  }
  if (needAccess === ACCESS_ENUMS.USER) {
    if (loginUserAccess === ACCESS_ENUMS.NOT_LOGIN) {
      return false;
    }
  }
  if (needAccess === ACCESS_ENUMS.ADMIN) {
    if (loginUserAccess !== ACCESS_ENUMS.ADMIN) {
      return false;
    }
  }
  return true;
};
